<template>
<view>
	<view class="header" v-if="!member_id">
		<input @input="search" placeholder="输入客户姓名"/>
	</view>
	<view class="table">
		
		<table border="0" width="95%" cellspacing="0" cellpadding="0"
		v-for="(item,index) in list" :key="index">
			<tr>
				<th colspan="2">项目名称</th>
				<td colspan="2">{{item.card_name}}</td>
			</tr>
			<tr>
				<th>客户姓名</th>
				<td>{{item.username}}</td>
				<th>剩余金额</th>
				<td>{{item.left_money}}</td>
			</tr>
			<tr>
				<th>支付金额</th>
				<th>账户抵扣</th>
				<th>代金券</th>
				<th>剩余次数</th>
			</tr>
			<tr>
				<td>{{item.pay_money}}</td>
				<td>{{item.offset_money}}</td>
				<td>{{item.give_money}}</td>
				<td>{{item.num}}</td>
			</tr>
		</table>
	</view>
</view>
</template>
<script>
import request from '@/util/request.js'
export default {
	data() {
		return {
			//oaRole 1:店长2:员工3:商户
			list:[],
			page:1,
			pageShow:true,
			member_id:0,
			formShow:false
		}
	},
	onLoad:function(e){
		this.member_id = e.id
		uni.showLoading({
		    title: '加载中'  
		});
		this.getList();
	},
	methods: {
		getList:function(){
		    var data = {
				page:this.page,
		        member_id:this.member_id,
				oa_id:uni.getStorageSync('oa_id'),
				keyword:this.keyword
		    }
		    var that = this
			request({
				url: 'manage/card/list',
				method: 'get',
				data:data,
				success: (res) => {
					uni.hideLoading();
					if(res.data.data.last_page <= that.page){
						that.pageShow = false
					}
					if(that.page == 1){
						that.list = res.data.data.data
					}else{
						var list = that.list
						that.list = list.concat(res.data.data.data)
					}
				},
			})
		},
		onReachBottom: function(){
			if(this.pageShow){
				 //当前不是最后一页可加载
				 this.page = this.page + 1
				 uni.showLoading()
				 this.getList();
			}
		},
		show:function(item){
			this.info = item
			this.formShow = true
		},
		close:function(){
			this.formShow = false
		},
		search:function(e){
			this.keyword = e.detail.value
			this.page = 1
			this.pageShow = true
			uni.showLoading()
			this.getList();
		},
	}
}
</script>
<style>
@import url("../css/public.css");
</style>